
#ifndef _MEMBER_AUDIOOUTPUT_H_
#define _MEMBER_AUDIOOUTPUT_H_

#include <BAudioOutput>

#ifdef linux
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/soundcard.h>
#endif

#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
#undef min
#undef max
#undef far
#undef near
#endif

#define audiooutput_member(audio)		((member_BAudioOutput*)audio->_ptr)

namespace BWE
{
	class member_BAudioOutput
	{
	public:
		member_BAudioOutput(BAudioOutput* audioOutput);
		~member_BAudioOutput();

		bool initFormat();

		void emitSignals();

		BAudioOutput*		boss;
		Format				format;
		int					fmtlen;
		int					channelCount;
		int					sampleRate;
		BByteArray			buffer;
		BAudio::State		state;
		bool				dirtyFormat;
#ifdef linux
		int					dsp_fd;
		FILE*				file_fd;
#endif

#ifdef _WIN32
		HWAVEOUT			hWaveOut;
		WAVEFORMATEX		wavform;
		WAVEHDR				wavhdr;
		CRITICAL_SECTION	bufferSection;
#endif
	};
}

#endif
